﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.UI.WebControls;
using PokerAssistant.Models;

namespace PokerAssistant.Controllers
{
    public class PokerController : Controller
    {
        //
        // GET: /Poker/

        public ActionResult Index()
        {
            var mäng = new Mäng(1);

            mäng.SegaKaardid();
            mäng.JagaMängijateleKaardid();
            
            ////FLOP
            //mäng.JagaÜhisedKaardid();
            ////TURN
            //mäng.JagaÜhisedKaardid();
            ////RIVER
            //mäng.JagaÜhisedKaardid();

            Console.WriteLine("Jagatud kaardid");
            foreach (var mängijaKäsi in mäng.Mängijad)
                Console.WriteLine("Mängija {0} - {1}", mäng.Mängijad.IndexOf(mängijaKäsi) + 1, String.Join(", ", mängijaKäsi.Kaardid));

            Console.WriteLine("Kaardid laual: {0}", String.Join(", ", mäng.KaardidLaual));

            Console.WriteLine("Kombinatsioone 6-st 3 kaupa: " + Tõenäosus.ArvutaKombinatsioonid(3, 6));

            return View(mäng);
        }

        public ActionResult GetCard(string cards) {

            var cardList = cards.Split(';').ToList();
            var diiler = new Diiler(true);
            var kaart = diiler.AnnaJärgmineKaart(cardList);


            return Json(new {kaart});
        }

        public ActionResult GetRoyalFlushProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber/5;
            return Json(new { probability = i});
        }

        public ActionResult GetStraightFlushProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber / 5;
            return Json(new { probability = randomNumber / 5 });
        }

        public ActionResult Get4OfAKindProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber / 5;
            return Json(new { probability = randomNumber / 5 });
        }

        public ActionResult GetFullHouseProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber / 5;
            return Json(new { probability = randomNumber / 5 });
        }

        public ActionResult GetFlushProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber / 5;
            return Json(new { probability = randomNumber / 5 });
        }

        public ActionResult GetStraightProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber / 5;
            return Json(new { probability = randomNumber / 5 });
        }

        public ActionResult Get3OfAKindProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber / 5;
            return Json(new { probability = randomNumber / 5 });
        }

        public ActionResult Get2PairsProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber / 5;
            return Json(new { probability = randomNumber / 5 });
        }

        public ActionResult Get1PairProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber / 5;
            return Json(new { probability = randomNumber / 5 });
        }

        public ActionResult GetHighHandProbability(string playerCard, string cardOnTable) {
            var random = new Random();
            var randomNumber = (double)random.Next(0, 100);
            var i = randomNumber / 5;
            return Json(new { probability = randomNumber / 5 });
        }
    }
}
